<template>
	<view class="wrap">
		<view class="header">
			<view class="userinfo">
				<view class="image" @click="navTo('info')">
					<u-avatar src="/static/aidex/images/user01.png"></u-avatar>
				</view>
				<view class="info" style="display: flex;justify-content: space-between;">
					<view>
						<view class="username">{{form.userName}}</view>
						<view class="usercode">{{form.nickName}}</view>
					</view>
					<view class="sign-in-images"><image src="/static/aidex/images/sign-in.png"></image></view>
				</view>
			</view>
		</view>
		<view class="list">
			<view>
				<u-cell-group class="personal-list">
					<u-gap height="20" bg-color="#f5f5f5"></u-gap>
					<u-cell icon="map" :iconStyle="{ color: '#316ede' }" title="账号安全" @click="navTo('pwd')"></u-cell>
					<u-gap height="20" bg-color="#f5f5f5"></u-gap>
					<u-gap height="20" bg-color="#f5f5f5"></u-gap>
					<u-gap height="20" bg-color="#f5f5f5"></u-gap>
					<u-button   @click="logout" :hair-line="false">退出登录</u-button>
				</u-cell-group>
				</u-cell-group>
				</u-cell-group>
			</view>
		</view>
	</view>
</template>
<script>
/**
 * Copyright (c) 2013-Now http://aidex.vip All rights reserved.
 */
export default {
	data() {
		return {
			iconSize: 38,
			form:{}
		};
	},
	computed: {
		avatarUrl() {
			// let url = this.vuex_user.avatarUrl || '/ctxPath/static/images/user1.jpg';
			// url = url.replace('/ctxPath/', this.vuex_config.baseUrl + '/');
			let url = this.vuex_config.baseUrl+ this.vuex_user.avatar ||  '/static/aidex/tabbar/my_2.png';
			url = this.replaceAll(url,'\\','/');
			return url + '?t=' + new Date().getTime();
		}
	},
	onLoad() {
		this.getMyProfile()
	},
	methods: {
		getMyProfile(){
			this.$u.api.getProfile().then(res => {
				if(res.code == 200){
					this.form = res.data.user
					uni.setStorageSync("username",this.form.userName)
				}
			})
		},
		navTo(url) {
			uni.navigateTo({
				url: url
			});
		},
		logout() {
			setTimeout(() => {
				uni.reLaunch({
					url: '/pages/sys/login/index'
				});
			}, 500);
		},
		upgrade(){
			// #ifdef APP-PLUS
			this.$u.api.upgradeCheck().then(res => {
				if (res.result == 'true'){
					uni.showModal({
						title: '提示',
						content: res.message + '是否下载更新？',
						showCancel: true,
						success: function (res2) {
							if (res2.confirm) {
								plus.runtime.openURL(res.data.apkUrl);
							}
						}
					});
				}else{
					this.$u.toast(res.message);
				}
			});
			// #endif
			// #ifndef APP-PLUS
			this.$u.toast('小程序端或H5端无需检查更新')
			// #endif
		}
	}
};
</script>
<style lang="scss">
@import 'index.scss';
page {
	background-color: #f5f5f5;
}
.image {
	display:flex;
	flex-wrap:wrap;
	align-items: center;
	justify-content: center;
}
.wrap .u-cell-box .u-cell_title{
	color:#202328;
}
.sign-in-images{
	width: 125rpx;
	height:50rpx;
	position: absolute;
	right: 0;
	top:5px;
	uni-image{
		width: 125rpx;
		height:50rpx;
	}
}
</style>
